<form class="form-horizontal form-confirm" id="form-add"
      action="{% url 'systems:menu_add' %}" method="post">

    <input type="hidden" id="id" name="id" value="{{ h_obj.id }}"/>

    <div class="form-group">
        <label class="control-label col-md-3">上级菜单</label>
        <div class="col-md-7">
            <select class="form-control select2 w-100" name="parent">
                <option></option>

                {{ h_menus|safe }}

            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">菜单名称</label>
        <div class="col-md-7">
            <input type="text" name="name" value="{{ h_obj.name }}"
                   class="form-control" placeholder="仅限30个汉字以内"/>
        </div>
        <h4 class="col-md-1" style="color: red;">*</h4>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">显示排序</label>
        <div class="col-md-7">
            <input type="text" name="sort" value="{{ h_obj.sort|default_if_none:'' }}"
                   class="form-control" placeholder="仅限数字"/>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">菜单图标</label>
        <div class="col-md-7">
            <input type="text" name="icon" value="{{ h_obj.icon|default_if_none:'' }}"
                   class="form-control" placeholder=""/>
        </div>
        <a class="col-md-2" href="#!" onclick="show_icons()">参考图标</a>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">拥有按钮</label>
        <div class="col-md-7">
            <select class="form-control select2 w-100" name="buttons" multiple="multiple" data-placeholder="可选择多个按钮">
                <option></option>

                {{ h_buttons|safe }}

            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">是否目录</label>
        <div class="col-md-7">
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_catalog" value="1"
                        {% ifequal h_obj.is_catalog 1 %} checked="" {% endifequal %}><span>是</span>
            </label>
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_catalog" value="0"
                        {% ifequal h_obj.is_catalog 1 %} {% else %} checked="" {% endifequal %}><span>否</span>
            </label>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">路由地址</label>
        <div class="col-md-7">
            <input type="text" name="web_path" value="{{ h_obj.web_path|default_if_none:'' }}"
                   class="form-control" placeholder=""/>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">是否外链</label>
        <div class="col-md-7">
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_link" value="1"
                        {% ifequal h_obj.is_link 1 %} checked="" {% endifequal %}><span>是</span>
            </label>
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_link" value="0"
                        {% ifequal h_obj.is_link 1 %} {% else %} checked="" {% endifequal %}><span>否</span>
            </label>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">是否页面缓存</label>
        <div class="col-md-7">
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_cache" value="1"
                        {% ifequal h_obj.is_cache 1 %} checked="" {% endifequal %}><span>是</span>
            </label>
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_cache" value="0"
                        {% ifequal h_obj.is_cache 1 %} {% else %} checked="" {% endifequal %}><span>否</span>
            </label>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">侧边栏是否可见</label>
        <div class="col-md-7">
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="visible" value="1"
                        {% ifequal h_obj.visible 0 %} {% else %} checked="" {% endifequal %}><span>可见</span>
            </label>
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="visible" value="0"
                        {% ifequal h_obj.visible 0 %} checked="" {% endifequal %}><span>不可见</span>
            </label>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">菜单状态</label>
        <div class="col-md-7">
            <label class="lyear-radio radio-inline radio-success">
                <input type="radio" name="status" value="1"
                        {% ifequal h_obj.status 0 %} {% else %} checked="" {% endifequal %}><span>启用</span>
            </label>
            <label class="lyear-radio radio-inline radio-danger">
                <input type="radio" name="status" value="0"
                        {% ifequal h_obj.status 0 %} checked="" {% endifequal %}><span>禁用</span>
            </label>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-md-3">数据归属部门</label>
        <div class="col-md-7">
            <select class="form-control select2 w-100" name="dept_belong_id">
                <option></option>

                {{ h_dept_belongs|safe }}

            </select>
        </div>
    </div>
    <div class="alert alert-warning alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        数据归属部门不填，则默认为当前创建用户的部门ID
    </div>

    {% csrf_token %}
</form>

<script>
    $(function() {
        // 初始化Select2
        $(".select2").select2();
    })
</script>